<?php
class FloorBrandAction extends BaseAction
{
    public function _initialize()
    {
        $this->assign('isMall', true);
        parent::_initialize();
    }

    public function index()
    {
    }

    public function home($mall, $floor, $brand)
    {
        //品牌基本信息
        //TODO 添加缓存处理 和 搜索里面获取方式相同
        if ($brand) {
            $bid = $brand['id'];
            $BrandModel = D('Brand');
            $BrandNewsModel = D('BrandNews');
            $brand = $BrandModel->find($bid);
            //品牌详细信息 获取图片
            $brand['image_url'] = $BrandModel->getBrandImage($brand['image']);
            //获取关注
            $brand['att_count'] = D('BrandAttention')->getAttCount($bid);
            //获取展示图
            $brand['slide'] = D('Slide')->getBrandOne($bid, $mall['id'], $floor['id']);
            //获取当前柜台活动
            $brand['dis'] = $BrandNewsModel->
                getOneNewAll($mall['id'], $floor['id'], $bid, 'id,title,keyword,start_time,end_time,detail');
            //获取所属商圈
            $brand['bus'] = M('Bus')->find($mall['cbd']);
            //获取品牌其他商场活动
            $brand['other_mall'] = $BrandNewsModel->getBrandOtherMallDis($mall['id'], $floor['id'], $bid);
            //获取品牌推荐
            $brand['similar'] = $this->getSimilarBrandById($bid);
            //获取楼层折扣信息
            $brand['mall_dis'] = D('Discount')->getMallDis($mall['id']);
            if (!empty($brand['dis'])) {
                $this->assign('day_time', $this->getThisDayTime());
            }
        }
        $uid = getLoginUserInfo();
        if ($uid) {
            D('BrandAttention')->checkUserIsAttrBrand($uid, $brand);
        }
        $titles = array($mall['name'], $floor['name'], $floor['sain'], $brand['ename'], $brand['name']);
        $this->seoSet($titles, $titles, msubstr(hh($mall['intr']), 0, 200));
        $this->assign('mall', $mall);
        $this->assign('floor', $floor);
        $this->assign('brand', $brand);
        $this->display('FloorBrand:home');
    }

    /**
     * 获取商场基本信息
     * @param $mid
     * @author Ice <iceinto@mallog.com.cn>
     */
    protected function getBaseInfo($mid, $fid, $bid)
    {
        //商场基本信息
        $MarketModel = D('Market');
        $mall = $MarketModel->find($mid);
        if (!$mall) {
            $this->errorLang('_MALL_NAME_ERROR_');
        }
        //商场滚动图
        $slider = $this->getSlide($mid, $fid, $bid);
        $this->assign('slider', $slider);
        return $mall;
    }
}

?>
